import { postForm, get, put } from '@/utils/request'

// 获取列表
export function getRecords(listQuery) {
  return get('/article/publish/list/page', listQuery)
}

// 获取文章发布的栏目列表
export function getArticlePublishSections(articleId) {
  return get('/article/publish/sections', { articleId: articleId })
}

// 上下架修改
export function optPublish(sectionId, articleId, status) {
  return postForm('/article/publish/opt/publish', { sectionId: sectionId, articleId: articleId, isPublish: status })
}

// 置顶修改
export function optSticky(sectionId, articleId, status) {
  return postForm('/article/publish/opt/sticky', { sectionId: sectionId, articleId: articleId, isSticky: status })
}

export function publish(articleId, sectionIds, status) {
  return postForm('/article/publish/batch/token', { articleId: articleId, sectionIds: JSON.stringify(sectionIds), reviewStatus: status })
}

export function add(optData) {
  return postForm('/article/publish', optData)
}

export function edit(optData) {
  return put('/article/publish', optData)
}

export function del(ids) {
  return postForm('/article/publish/del/batch', { pkIds: JSON.stringify(ids) })
}

export default { add, edit, del }
